<?php
 
class ActiveRecord extends CActiveRecord
{
	public function delete($soft=true)
	{
		if( $soft===true && $this->hasAttribute('deleted')===true )
		{
			$this->deleted = 1;
			$this->save(false);
			return true;
		}
		else
			return parent::delete();
	}

	public function beforeSave()
	{
		if( $this->isNewRecord===true )
		{
			if( $this->hasAttribute('created')===true )
				$this->created = date('Y-m-d H:i:s');

			if( $this->hasAttribute('deleted')===true )
				$this->deleted = 0;
		}
		else
		{
			if( $this->hasAttribute('updated')===true )
				$this->updated = date('Y-m-d H:i:s');
		}

		return parent::beforeSave();
	}
}
